﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Tayninh2011
{
    public sealed partial class FrmTnMapTool : RootForm
    {
        private static readonly FrmTnMapTool meForm=new FrmTnMapTool();
        private FrmTnMap frmMap = FrmTnMap.CallMe;
        private FrmTnMapTool()
        {
            InitializeComponent();
            axToolbarControl1.SetBuddyControl(frmMap.axMapControl1);
            axToolbarControl2.SetBuddyControl(frmMap.axMapControl1);
            axToolbarControl3.SetBuddyControl(frmMap.axMapControl1);
        }

        #region Singleton

        public static FrmTnMapTool CallMe
        {
            get { return meForm; }
        }

        public new void Show()
        {
            if (isShown)
            {
                
                base.Show();
            }
            else
            {
                base.Show();
                
                isShown = true;
            }
        }
        private static bool isShown = false;

        static FrmTnMapTool()
        {

            meForm.FormClosing += new FormClosingEventHandler(frm_FormClosing);

        }
        private static void frm_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            isShown = false;
            meForm.Hide();
            //if (MessageBox.Show("Bạn muốn thoát khỏi chương trình", "Thoát", MessageBoxButtons.OKCancel) == DialogResult.OK)
            //{
                
            //    Application.ExitThread();
            //    Application.Exit();
            //}
        }

        #endregion Singleton
    }
}
